package Q454

class Main {


}


 class Solution {
    fun fourSumCount(A: IntArray, B: IntArray, C: IntArray, D: IntArray): Int {
        val countAB: MutableMap<Int, Int> = HashMap()
        for (u in A) {
            for (v in B) {
                countAB[u + v] = countAB.getOrDefault(u + v, 0) + 1
            }
        }
        var ans = 0
        for (u in C) {
            for (v in D) {
                if (countAB.containsKey(-u - v)) {
                    ans += countAB[-u - v]!!
                }
            }
        }
        return ans
    }
}





